#!/bin/bash
# GPLv3 or later 2017 Jeff Cliff
#
# See COPYING.GPL
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

DOES_IFCONFIG_EXIST=`which ifconfig`
if [[ -z $DOES_IFCONFIG_EXIST ]]; then
IPCOMMAND="ip address"
else
IPCOMMAND="ifconfig"
fi
echo "IPCOMMAND" $IPCOMMAND 

# sometimes ifconfig is available, this is where to find/change it if it is. maybe we should autodetect if it does

network=`$IPCOMMAND | grep inet | grep -iv inet6  | grep -iv 127.0.0.1 | awk -F' ' '{print $2}' | awk -F'.' '{print $1 "." $2 "." $3 ""}' | sed -s "s/addr://g"`
echo $network
for y in $network; do
for x in `seq 255` ;
do
#echo "network:" $y
#echo "x:" $x
#echo "network.x:" $y.$x
#echo ping -c 1 $y.$x
ping -c 1 $y.$x | grep -i 'ttl' |  grep -iv 'Unreachable' &
done
echo $y ; done
